<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试ajax</title>
</head>

<body>
    <div style="width: 1000px;height:500px;border: 1px solid red;"></div>
    <input type="button" value="点击这里">
</body>
<script>
    function xmlhttp() {
        var xhr = new XMLHttpRequest();
        xhr.open('get', 'ceshi.html', true);
        xhr.send();
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200 || xhr.status == 0) {
                    console.log(xhr.responseText);
                    document.querySelector('div').innerHTML = xhr.responseText + '!!';
                }
            }
        }
    }
    document.querySelector('input').addEventListener('click', xmlhttp)
</script>

</html>